#!/bin/ksh
#
# makman -- make lsof 4.x man page for ftp tree

SD=${HOME}/src/lsof4
cd $SD

# Get version number.

V=`sed '/VN/s/.ds VN \(.*\)/\1/' version`
if test $? -ne 0
then
  echo $V
  exit 1
fi

# Handle optional edition suffix.

if test $# -gt 0
then
  if test $# -gt 1
  then
    echo "Usage: makeman [edition]"
    exit 1
  fi
  V=${V}$1
fi

# Define man file names.

MS=Lsof.8
MD=${SD}/support/lsof.8
MF=${SD}/support/lsof_${V}.man

# Set exit cleanup trap.

trap 'rm -rf $MD $MF; exit' 1 2 3 15

# Create manual page files.

echo Producing $MD
soelim < $MS > $MD
echo Producing $MF
nroff -man $MD | colcrt - | cat -s > $MF
rm -f $MD
ls -l $MF
